package com.yu.work;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;

import com.yu.work.adapter.MainActivityPagerAdapter;
import com.yu.work.fragment.DrawNumberFragment;
import com.yu.work.fragment.RecordListFragment;

import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.ViewInject;
import org.xutils.x;

import java.util.ArrayList;
import java.util.List;

/**
 * 主界面
 */
@ContentView(R.layout.activity_main)
public class MainActivity extends AppCompatActivity {

    @ViewInject(R.id.pager_container)
    private ViewPager mViewPager;

    private MainActivityPagerAdapter mPagerAdapter;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        x.view().inject(this);
        initViewPager();
    }

    /**
     * 初始化ViewPager
     */
    private void initViewPager() {
        List<Fragment> fragments = new ArrayList<>();
        fragments.add(new DrawNumberFragment());
        fragments.add(new RecordListFragment());

        mPagerAdapter = new MainActivityPagerAdapter(getSupportFragmentManager(), fragments);
        mViewPager.setAdapter(mPagerAdapter);
    }

}
